$(document).ready(function(){
	vm.load_list();
	$("#page_title").html("分析数据选项");
});
var vm = avalon.define({
	$id:"main_controller",
	//----------------
	//toast的信息
	toast_msg:'',
	//是否要展示toast
	is_toast_show:false,
	//定时器
	$timeout:0,
	//消息隐藏
	clear_toast:function(){
		//设置定时器
		if(vm.$timeout){
			clearTimeout(vm.$timeout);
		}
		vm.$timeout = setTimeout(function(){
			vm.is_toast_show = false;
			vm.toast_msg = '';
		},3000);		
	},	
	//-----------------		
	list:[],	
	//是否正在加载
	is_loading:false,
	load_list:function(){
		vm.is_loading = true;
		vm.list = [];
		$.ajax({
			type:"post",
			url:get_health_url,
			dataType:"json",
			success:function(data){
				console.log(data);
				vm.list = data;
				vm.is_loading = false;
			},
			error:function(){
				vm.toast_msg = "网络错误";
				vm.is_toast_show = true;
				vm.clear_toast();					
			},
		});		
	},
	/**
	 * 跳转到分析页面
	 * @param {Object} index
	 */
	go_to_item:function(index){
		var obj = vm.list[index];
		var testname = vm.list[index].testname;
		var unit = vm.list[index].unit;
		var limithigh = vm.list[index].limithigh;
		var limitlow = vm.list[index].limitlow;
		var libraryname = vm.list[index].libraryname;
		var is_do = false;
		if(libraryname == "数值型"){
			is_do = true;
		}
		var other_params = "";
		if(testname == "血压"){
			other_params = "&flag=true";			
		}
		location.href = chart_url+"?dicttestitemid="+vm.list[index].dicttestitemid
				+other_params+"&testname="+encodeURI(encodeURI(testname))+"&unit="+encodeURI(encodeURI(unit))
				+"&limithigh="+limithigh+"&limitlow="+limitlow+"&is_do="+is_do;
	},
});
avalon.scan();
avalon.ready(function(){
	$('body').css('opacity',1);
});
